[id].vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { useBrandDetailData } from "./useBrandDetailData"
  4. import { setBrandFavoriteApi } from "~/api/model/brand"
  5. import { useUserStore } from "@/stores/modules/user"
  6. import { ConstKeys } from "~/enums/const-enums"
  7. const route = useRoute()
  8. const id = route.params.id
  9. const { data, pending, error, refresh } = await useAsyncData(
  10. "brand-detail",
  11. () => $fetch(`${ConstKeys.DOMAINPRO}/client/brand/detail`, { params: { id } })
  12. )
  13. const seoData = data.value?.result
  14. useHead({
  15. title: `Shop ${seoData?.brandName} Brand Wholesale | EJET Selection`,
  16. meta: [
  17. {
  18. name: "description",
  19. content: `Explore EJET Selection's Top Brands, featuring trusted Chinese wholesale suppliers known for quality and innovation. Discover unique and exclusive home decor products for your store.`,
  20. },
  21. {
  22. property: "og:title",
  23. content: `Shop ${seoData?.brandName} Brand Wholesale | EJET Selection`,
  24. },
  25. {
  26. property: "og:description",
  27. content: `Explore EJET Selection's Top Brands, featuring trusted Chinese wholesale suppliers known for quality and innovation. Discover unique and exclusive home decor products for your store.`,
  28. },
  29. {
  30. property: "og:image",
  31. content: seoData?.headeImage,
  32. },
  33. {
  34. property: "og:url",
  35. content: `${ConstKeys.DOMAINPRO}/brand/${id}`,
  36. },
  37. {
  38. property: "og:type",
  39. content: "website",
  40. },
  41. {
  42. property: "twitter:title",
  43. content: `Shop ${seoData?.brandName} Brand Wholesale | EJET Selection`,
  44. },
  45. {
  46. property: "twitter:description",
  47. content: `Explore EJET Selection's Top Brands, featuring trusted Chinese wholesale suppliers known for quality and innovation. Discover unique and exclusive home decor products for your store.`,
  48. },
  49. {
  50. property: "twitter:site",
  51. content: `${ConstKeys.DOMAINPRO}/brand/${id}`,
  52. },
  53. {
  54. property: "twitter:image",
  55. content: seoData?.headeImage,
  56. },
  57. {
  58. property: "twitter:card",
  59. content: "summary_large_image",
  60. },
  61. ],
  62. link: [
  63. {
  64. rel: "canonical",
  65. href: `${ConstKeys.DOMAINPRO}/brand/${id}`,
  66. },
  67. ],
  68. })
  69. const userStore = useUserStore()
  70. const { isLogin } = storeToRefs(userStore)
  71. const { openLoginModal } = useLoginModal()
  72. const { openMessageModal } = useMessageModal()
  73. const {
  74. detail,
  75. getDetailInfo,
  76. brandGoodsList,
  77. page_size,
  78. changePage,
  79. total,
  80. currentPage,
  81. handleSelectedCategory,
  82. } = useBrandDetailData()
  83. const tagList = computed(() => {
  84. console.log("taglist", detail.value?.brandTag?.split(","))
  85. return detail.value?.brandTag?.split(",") || []
  86. })
  87. async function onFavorite(item: any) {
  88. try {
  89. const { status } = await openLoginModal()
  90. if (status) {
  91. const params = { bid: item.id, type: item.isFavorite ? 2 : 1 }
  92. await setBrandFavoriteApi(params)
  93. item.isFavorite = !item.isFavorite
  94. ElMessage({
  95. message: `${item.isFavorite ? "Add" : "Remove"} to My Favourites Successfully`,
  96. type: "success",
  97. plain: true,
  98. })
  99. }
  100. } catch (error) {
  101. console.log(error)
  102. }
  103. }
  104. async function getAsyncData() {
  105. await getDetailInfo()
  106. await handleSelectedCategory("")
  107. }
  108. getAsyncData()
  109. async function openMessage() {
  110. const { status } = await openLoginModal()
  111. if (status) {
  112. const res = await openMessageModal(detail.value)
  113. console.log(res)
  114. }
  115. }
  116. </script>
  117. <template>
  118. <div class="">
  119. <img
  120. :src="detail?.headeImage"
  121. class="w-full h-400px object-cover"
  122. alt=""
  123. srcset=""
  124. />
  125. <div
  126. class="w-1400px mx-auto pt-110px pb-20px pos-relative flex justify-between items-center"
  127. >
  128. <div
  129. class="w-160px h-160px pos-absolute top--80px left-0 overflow-hidden b-rd-10px bg-#fff"
  130. >
  131. <img :src="detail?.brandLogo" class="object-contain" alt="" srcset="" />
  132. </div>
  133. <div class="w-1000px">
  134. <h1 class="fw-700 text-32px text-#363C40 !mb-24px">
  135. {{ detail?.brandName }}
  136. </h1>
  137. <div class="flex text-#999999 lh-24px">
  138. {{ detail?.brandStory }}
  139. </div>
  140. </div>
  141. <div v-if="!isLogin">
  142. <el-button
  143. type="primary"
  144. plain
  145. class="w-160px !bg-#C58C64 !text-#fff !h-40px !text-16px !fw-500 !b-rd-150px"
  146. @click="openLoginModal"
  147. >
  148. Sign on EJET
  149. </el-button>
  150. </div>
  151. <div v-else class="flex items-center">
  152. <el-button
  153. class="!bg-#CC9879 !text-#fff !w-120px !h-40px !b-rd-150px"
  154. @click="onFavorite(detail)"
  155. >
  156. {{ detail?.isFavorite ? "Unfollow" : "Follow" }}
  157. </el-button>
  158. <!-- <el-button class="!text-#C58C64 !w-120px !h-40px !b-rd-150px !ml-18px" @click="openMessage">
  159. Message
  160. </el-button> -->
  161. </div>
  162. </div>
  163. <div
  164. v-if="detail?.brandTag && tagList.length"
  165. class="flex flex-wrap gap-20px w-1400px mx-auto mb-100px h-38px overflow-hidden"
  166. >
  167. <div
  168. v-for="(item, index) in tagList"
  169. :key="index"
  170. class="b-1px b-solid b-#d6ab92 b-rd-30px px-20px lh-36px text-#d6ab92"
  171. >
  172. {{ item }}
  173. </div>
  174. </div>
  175. <div class="w-1400px mx-auto mb-160px">
  176. <!-- <h2 class="!mb-68px fw-700 text-24px text-#333">
  177. All Products
  178. </h2> -->
  179. <div
  180. v-if="brandGoodsList.length"
  181. class="grid grid-gap-x-65px grid-gap-y-65px grid-cols-4"
  182. >
  183. <div v-for="item in brandGoodsList" :key="item.id">
  184. <common-goods-item :item />
  185. </div>
  186. </div>
  187. <common-empty v-else title="">
  188. <template #icon>
  189. <img
  190. src="~/assets/images/featured_empty.png"
  191. class="w-200px h-200px"
  192. alt=""
  193. srcset=""
  194. />
  195. </template>
  196. </common-empty>
  197. <div v-if="brandGoodsList.length" class="mt-60px flex justify-center">
  198. <el-pagination
  199. v-model:current-page="currentPage"
  200. :page-size="page_size"
  201. :pager-count="10"
  202. layout="prev, pager, next"
  203. :total="total"
  204. @change="changePage"
  205. />
  206. </div>
  207. </div>
  208. <business-brand-footer />
  209. <AppFooter />
  210. </div>
  211. </template>
  212. <style lang="less" scoped></style>